#!/usr/bin/env python3
# -*- coding: utf-8 -*-
' main entry '
__author__ = 'pingwu you'

def slice():
    ls=[0,1,2,3,4,5,6,7,8]
    #从0开始，到3索引之前的每1个取一个小片的分片！！
    print(ls[0:3]) #print(ls[:3]) 前空则默认为0
    #每2个取1次
    print(ls[2:8:2])
    #-1则为取倒数第一个
    print(ls[-1])
    print(ls[-2:-1]) 
    print(ls[-2:]) #默认为与-1不同    

    print("ABCDEFGH"[::2])
    print("ABCDEFGH"[-3::2])

def list_gen():
    #for 前为表达式 即对原始x进行再重构，后面if为过滤true/false
    ls=["hello--"+str(x) if x>12 else "特殊值999" for x in range(1,31) if x%2==0]
    print(ls)

def genertor():
    print('step 1')
    yield 1
    print('step 2')
    yield(3)
    print('step 3')
    yield(5)
    return 9999